<script>
import { unique } from 'board/utils/string'

export default {
    name: 'BiToolbarItem',
    inject: ['BiToolbar'],
    props: {
        position: {
            type: String,
            default: 'left',
            validator (value) {
                return ['left', 'right'].indexOf(value) >= 0
            }
        }
    },
    created () {
        this.id = unique()
        this.BiToolbar.addItem({
            id: this.id,
            props: this.$props,
            render: () => {
                return this.$scopedSlots.default()
            }
        })
    },
    beforeDestroy () {
        this.BiToolbar.removeItem(this.id)
    },
    render () {
        return null
    }
}
</script>